import router from '@system.router';

var timer = null;

export default {
    data: {
        seconds: 3
    },
    onShow() {
        timer = setInterval(this.onTimeout, 1000);
    },
    onTimeout() {
        this.seconds--;

        if (this.seconds == 0) {
            clearInterval(timer);
            timer = null;

            this.seconds = "";

            router.replace({
                uri: "pages/training/training",
                params: {
                "durationSelected": this.durationSelected,
                "rhythmSelected": this.rhythmSelected
                }
            });
        }
    }
}
